'use strict';

angular.module('Hospital.auth.login', ['ngRoute', 'Hospital.services'])

.config(['$routeProvider', function($routeProvider) {
	$routeProvider.when('/login', {
		templateUrl: 'views/auth/login.html'
	});		
}])

.controller('loginCtrl', ['$location', '$http', '$scope','Auth',  function($location, $http, $scope, Auth) {
	$scope.login = function() {
		$http.post(API_SERVER + 'auth/login', $scope.data).success(function(res) {
			console.log(res);
          if(res && res.code === 0) {
			  //delete res.data.adminId;
			  //delete res.data.password;
			  //$scope.admin=res.data.username;
              Auth.login(res.data);
			  window.location='#/message';/*首页封面*/
        }else{
        	alert("登录失败,请检查账号密码是否正确！");
        }
		})
	};
	
}]);
